package com.recipedb.recipedb.repository;

import com.recipedb.recipedb.entity.Likes;
import com.recipedb.recipedb.entity.LikesId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface LikesRepository extends JpaRepository<Likes, LikesId> {
    // 在 LikesRepository 接口中添加
    Optional<Likes> findByUserIdAndRecipeId(Long userId, Long recipeId);
    // 按菜谱ID查询并按创建时间降序排序
    List<Likes> findByRecipeIdOrderByCreatedAtDesc(Long recipeId);
}
